package com.netease.rmi.server;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

/**
 * @author bjweitingting
 * @description
 * @date 2018/8/22
 **/
public class UserHandlerImpl extends UnicastRemoteObject implements UserHandlerInterface {
    // 该构造期必须存在，因为集继承了UnicastRemoteObject类，其构造器要抛出RemoteException
    public UserHandlerImpl() throws RemoteException {
        super();
    }

    @Override
    public String getUserName(int id) throws RemoteException {
        return id+"";
    }

    @Override
    public int getUserCount() throws RemoteException {
        return 0;
    }

    @Override
    public User getUserByName(String name) throws RemoteException {
        User user=new User();
        user.setAge(18);
        user.setName(name);
        System.out.println("user="+user.getClass().getClassLoader().toString());
        return user;
    }
}
